package lanou3g.myfirstapp36kr.srcollView;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * Created by dllo on 16/8/9.
 */
public class ObservableScrollView extends ScrollView {
    private ScrollviewListener scrollviewListener = null;

    public ObservableScrollView(Context context) {
        super(context);
    }

    public ObservableScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ObservableScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setScrollViewListener(ScrollviewListener scrollViewListener){
        this.scrollviewListener = scrollViewListener;
    }

    @Override
    protected void onScrollChanged(int x, int y, int oldx, int oldy) {
        super.onScrollChanged(x, y, oldx, oldy);
        if (scrollviewListener != null){
            scrollviewListener.onScrollChanged(this,x,y,oldx,oldy);
        }
    }
}
